/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import beans.DBMS;
import beans.Order;
import java.sql.ResultSet;
import java.util.Calendar;
import javax.mail.Flags;

/**
 *
 * @author appi
 */
public class OrderDao {

    private static int oid;

    // private static DBMS d = new DBMS();
    // by using private, 'd' would be no longer available outside this class.
    // by using static, 'd' can be used by all the following methods.
    // it means, no need to create obj 'd' in each method
    public static int addOrder(Order o) {
        DBMS d = new DBMS();


            String sql = "insert into `order` (`email`, `deldate`, `total`, `shipadd`) values('" + o.getEmail() + "','" + o.getDeldate() + "'," + o.getTotal() + ",'" + o.getShipadd() + "')";
        try {
            if (d.guid(sql) == 1) {

                ResultSet rs = null;
                String sql1 = "select MAX(`oid`) AS `A` from `order`";
                rs = d.gselect(sql1);
                while(rs.next()){
                    oid= rs.getInt("A");
                }

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return oid;

    }
}
